using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AutoDisappear : MonoBehaviour
{
    [SerializeField] private bool _isAutoDisappear = true;

    [SerializeField] private float _disappearDuration = 2f;

    private WaitForSeconds _disappearCoroutine;

    private void Awake()
    {
        _disappearCoroutine = new(_disappearDuration);
    }
    private void OnEnable()
    {
        if (_isAutoDisappear)
            StartCoroutine(AutoDisappearCo());
    }

    private IEnumerator AutoDisappearCo()
    {
        yield return _disappearCoroutine;

        PoolManager.Instance.Delease(gameObject);
    }
}
